package com.techstar.ats.codec.history.decoder;

import io.netty.buffer.ByteBuf;
import com.techstar.ats.codec.StringCodec;
import com.techstar.ats.dxp.history.F23HistoryRecord;
import com.techstar.ats.dxp.history.rep.F23HistorySchedule;
import com.techstar.ats.type.SubType;

public enum F23HistoryScheduleDecoder implements ScheduleDecoder<F23HistorySchedule> {
	INSTANCE;

	public F23HistorySchedule create() {
		return new F23HistorySchedule();
	}

	public void decode(ByteBuf buf, F23HistorySchedule value) {
		ScheduleDecoder.super.decode(buf, value);
		if(SubType.DATA.equals(value.sub)) {
			value.group = (new StringCodec(9)).get(buf);
			int cnt = buf.readUnsignedShort();

			for(int i = 0; i < cnt; ++i) {
				F23HistoryRecord record = F23HistoryRecordDecoder.INSTANCE.create();
				F23HistoryRecordDecoder.INSTANCE.decode(buf, record);
				value.records.add(record);
			}
		}

	}
}
